<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .layui-form-item {
            display: inline-block;
        }

        .layui-input-inline {
            width: 260px;
        }

        .layui-form-label {
            width: 140px;
        }

        .mukuai {
            padding-top: 20px;
            border-top: 1px solid #f3f3f3;
            border-bottom: 1px solid #f1f1f1;
            margin-bottom: 20px;
        }
        .float-z{
            position: fixed;
            top:10%;
            z-index:1001;
            width: 100%;
            overflow-x: hidden;
            overflow-y: auto;
            display: none;
        }
        .block-msg{
            position: fixed;
            width: 100vw;
            height: 100vh;
            background: rgba(0,0,0,0.5);
            z-index:1000;
            display: none;
        }
        .left-yuan{
            display: block;
            position: fixed;
            left: 3%;
            top:5%;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            line-height: 30px;
            padding:10px;
            background-color:#1accaa;
            color:#f3f3f3;
        }
        .caption{
            border: 1px solid #666;
            background-color: #fff;
            margin: 0px auto;
            /* position: absolute;
            top: 20%;
            left: 50%;
            margin-left: -450px;
            z-index: 1001;    
            display: none; */
        }
        .caption caption{
            text-align: left;
            text-indent:1em;
            height: 30px;
            line-height: 30px;
        }
        .caption thead{
            border-bottom:1px solid #333;
        }
        .caption tr td{
            width: 300px;
            height: 40px;
            line-height: 40px;
            border: none;
        }
        .caption tr td input{
            width: 160px;
            display: inline-block;
            border: none;
            text-align: center;
            background-color: #f5f5f5;
            color: #222;
            height: 30px;
            line-height: 30px;
            margin-left: 5px;
        }
        .caption tr td label{
            width: 120px;
            height: 30px;
            line-height: 30px;
            display: inline-block;
            text-align: right;
        }
        .caption tfoot tr td{
            border-top: 1px solid #888;
            height: 45px;
            text-align: center;
        }
        .caption tfoot td p{
            margin: 0px;
            width: 94%;
            padding: 0px 3%;
            text-align: right;
        }
        .caption tfoot tr td button{
            background-color: #1Accee;
            color: #fff;
            border: 1px solid #1Acca1;
            border-radius: 10px;
            height: 30px;
            line-height: 30px;
            width: 200px;
            font-size: 16px;
        }
        .table-message {  
            background-color: #f1f1f1;
            margin:20px auto;
            border-collapse: collapse;  
            width: 95%;  
        }  
        .table-message th, td {  
            border: 1px solid black;  
            padding: 8px;  
            text-align: left;  
        }  
        .table-message th {  
            background-color: #f2f2f2;  
        }  
        .logo {  
            text-align: center;  
        }  
        .footer {  
            text-align: right;  
        }  
    </style>
    <script>
        function hidemsg(){
            document.getElementById('mgk').style = 'display:none';
            document.getElementById('preview').style = 'display:none';
            document.getElementById('order-list').style = 'display:none';
        }
        function showmsg(){
            document.getElementById('mgk').style = 'display:block';
            document.getElementById('order-list').style = 'display:block';
        }
        function add_preview(){
            document.getElementById('mgk').style = 'display:block';
            document.getElementById('preview').style = 'display:block';
        }
        function search_company(){
            let company_name = document.getElementById('company_name').value;
            $.ajax({
                url: '/cdata', // 你的 PHP 脚本的 URL
                type: 'post', // 请求类型，可以是 'GET' 或 'POST'
                dataType: 'json', // 预期服务器返回的数据类型
                data: {company_name:company_name},
                success: function (res) {
                    console.log(res);
                    let string = '';
                    if (res.code == 200) {
                        res.data.forEach(item => {
                            string += '<option value="' + item.company_name + '">' + item.company_name + '</option>';
                        });
                        document.getElementById('company').innerHTML = string;
                    }
                }
            });
        }
        function set_company(){
            let company_name = document.getElementById('company_name').value;
            $.ajax({
                url: '/cdata', // 你的 PHP 脚本的 URL
                type: 'post', // 请求类型，可以是 'GET' 或 'POST'
                dataType: 'json', // 预期服务器返回的数据类型
                data: {company_name:company_name},
                success: function (res) {
                    console.log(res);
                    let string = '';
                    if (res.code == 200) {
                        if (res.data[0]){
                            document.getElementById('nickname').value = res.data[0].nickname;
                            document.getElementById('address').value = res.data[0].address;
                            document.getElementById('company_name').value = res.data[0].company_name;
                            document.getElementById('mobile').value = res.data[0].mobile;
                        }
                    }
                }
            });
        }
        function set_ccep(){
            let amount = 0,tr = document.getElementById('list-message').getElementsByTagName('tr'),td = [],string = '';
            for(let j=0;j<tr.length;j++){
                string += '<tr>';
                td = tr[j].getElementsByTagName('td');
                for(let i=0;i<10;i++){
                    if (i == 8) {
                        amount = parseFloat(td[i].innerHTML) + amount;
                    }
                    string += '<td>' + td[i].innerHTML + '</td>';
                }
                console.log(amount);
                string += '</tr>';
            }
            document.getElementById('list-ccep').innerHTML = string;
            document.getElementById('amount').innerText = amount;
            hidemsg();
            add_preview();
        }
        function look_tr(uniqid){
            let key,input_all = document.getElementsByTagName('input'),
            select_all = document.getElementsByTagName('select');
            for (let i = 0; i < input_all.length; i++) {
                input_all[i].value = info_data[uniqid][input_all[i].id];
            }
            for (let i = 0; i < select_all.length; i++) {
                select_all[i].change();
            }
        }
    </script>
</head>

<body>
<a class="left-yuan" href="javascript:;" onclick="showmsg()">列表</a>
<div class="block-msg" id="mgk" onclick="hidemsg()"></div>
<div class="float-z" id="preview">
    <table class="table-message" id="table-message">  
        <thead>
            <tr>  
                <td class="logo" rowspan="3" style="vertical-align: middle;">  
                    <!-- 在这里插入公司LOGO图片，例如：<img src="company_logo.png" alt="公司LOGO"> -->  
                    公司LOGO  
                </td>  
                <td colspan="9" style="text-align: center;">  
                    <h2>温州市龙安法兰有限公司</h2>  
                </td>  
            </tr>  
            <tr> 
                <td colspan="3">询价方</td>  
                <td colspan="3">报价方</td>  
                <td>报价编号:{$info.order_no|default=$data.order_no}</td>
            </tr>  
            <tr>  
                <td colspan="3">客户公司：
                    <input type="text" list="company" id="company_name" value="{$info.company_name|default=''}" onchange="set_company()" onkeypress="search_company()">
                    <datalist id="company">
                        {volist name="data.company" id="value"}
                        <option value="{$value.company_name}">{$value.company_name}</option>
                        {/volist}
                    </datalist>
                </td>  
                <td colspan="3">报价公司：温州市龙安法兰有限公司</td> 
                <td colspan="3">报价日期：{$info.order_no|default=$data.day}</td>  
            </tr>  
            <tr> 
                <td></td>
                <td colspan="3">公司地址：<input type="text" id="address" value="{$info.company_address|default=''}"></td>  
                <td colspan="3">公司地址：浙江省温州市龙湾区龙安法兰有限公司</td>  
                <td colspan="3">交货期：<input type="date" id="end_time" value="{$info.end_time|default=''}"></td>  
            </tr>  
            <tr>  
                <td></td>
                <td colspan="3">联系人：<input type="text" id="nickname" value="{$info.company_contacts|default=''}"></td>  
                <td colspan="3">联系人：杨天津</td>  
                <td colspan="3">报价员：<input type="text" id="name" value="{$info.quoter|default=''}"></td>  
            </tr>  
            <tr> 
                <td></td>
                <td colspan="3">联系方式：<input type="text" id="mobile" value="{$info.company_mobile|default=''}"> </td>  
                <td colspan="3">联系方式：</td> 
                <td colspan="3">审核员：杨天津</td>  
            </tr>  
            <tr>  
                <th>产品名称</th>  
                <th>产品明细</th>  
                <th>材质</th>  
                <th>数量</th>  
                <th>单位</th>  
                <th>单重</th>  
                <th>总重</th>  
                <th>单价</th>  
                <th>总价</th>  
                <th>备注</th>  
            </tr>  
        </thead>
        <tbody id="list-ccep">
            {php}foreach($info['data'] AS $key => $value){ {/php}
            <tr id="tr{$key}">
                <td>{$value.goods_name}</td>
                <td>{$value.goods_attr}-{$value.goods_pressure}-{$value.goods_piping}-{$value.goods_ss}</td>';
                <td>{$value.material}</td>
                <td>{$value.number}</td>
                <td>{$value.unit}</td>
                <td>{$value.goods_total_price}</td>
                <td>{$value.goods_weight1}</td>
                <td>{$value.goods_total_weight}</td>
                <td>{$value.goods_total_amount}</td>
                <td>{$value.info}</td>
            </tr>
            {php} } {/php}
        </tbody>
        <!-- 以下是产品信息的空行，您可以根据实际需要添加更多行 -->  
        <tfoot>

        
        <!-- ... 更多产品信息行 ... -->  
            <tr>  
                <th>合计</th>  
                <td colspan="8" id="amount">{$info.amount|default=0}</td>  
                <td></td>  
            </tr>  
            <tr>  
                <td colspan="10" style="text-align: left;">  
                    1、此金额含增值税（13%）的人民币<br>  
                    2、运费说明：以上价格含陆运运费。<br>  
                    3、付款条件：协商。<br>  
                    4、付款要求：只接受支票、电汇、转账，不收期票和银行承兑汇票。  
                </td>  
            </tr>  
            <tr>  
                <td colspan="10" style="text-align: right;">  
                    单位报价章：<br>  
                    Unit quotation seal：<br>  
                    审核：<br>  
                    本报价请购方签字盖章后生成订单<br>  
                    Review: the order will be generated after the buyer signs and seals the price  
                </td>  
            </tr>  
        </tfoot>
    </table>
</div>
<div class="float-z" id="order-list">
    <table class="layui-table">
        <thead>
            <tr>
                <th>产品名称</th>
                <th>产品明细</th>
                <th>材质</th>
                <th>数量</th>
                <th>单位</th>
                <th>单重</th>
                <td>总重</td>
                <td>单价</td>
                <td>总价</td>
                <td>备注</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody id="list-message">
            {php}foreach($info['data'] AS $key => $value){ {/php}
            <tr id="tr{$key}">
                <td>{$value.goods_name}</td>
                <td>{$value.goods_attr}-{$value.goods_pressure}-{$value.goods_piping}-{$value.goods_ss}</td>';
                <td>{$value.material}</td>
                <td>{$value.number}</td>
                <td>{$value.unit}</td>
                <td>{$value.goods_total_price}</td>
                <td>{$value.goods_weight1}</td>
                <td>{$value.goods_total_weight}</td>
                <td>{$value.goods_total_amount}</td>
                <td>{$value.info}</td>
                <td>
                    <a href="javascript:look_tr('{$key}');">查看</a>
                    <a href="javascript:del_tr('{$key}');">删除</a>
                </td>
            </tr>
            {php} } {/php}
        </tbody>
        <tfoot>
            <tr>
                <td colspan="11">
                    <button class="layui-btn" onclick="set_ccep()">确认</button>
                </td>
            </tr>
        </tfoot>
        </table>
</div>
<div class="x-body">
    <!-- <form class="layui-form"> -->
    <div class="layui-form-item">
        <label for="name" class="layui-form-label">
            产品标准
        </label>
        <div class="layui-input-inline">
            <select id="goods_standard" name="goods_standard" class="layui-select"
                    onchange="set_goods_name(this.value)">
                <option value="HG/T20592-2009">HG/T20592-2009</option>
                <option value="HG/T20615-2009">HG/T20615-2009</option>
                <option value="非标法兰">非标法兰</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label for="desc" class="layui-form-label">
            产品名称
        </label>
        <div class="layui-input-inline">
            <select name="goods_name" id="goods_name" onchange="set_goods_strand(this.value)" class="layui-select">
                <option value="对焊环松套法兰(PJ)">对焊环松套法兰(PJ)</option>
                <option value="螺纹法兰(Th)">螺纹法兰(Th)</option>
                <option value="承插焊法兰(SW)">承插焊法兰(SW)</option>
                <option value="法兰盖(BL)">法兰盖(BL)</option>
                <option value="对焊带颈法兰(WN)">对焊带颈法兰(WN)</option>
                <option value="带颈平焊法兰(SO)">带颈平焊法兰(SO)</option>
                <option value="平焊法兰(PL)">平焊法兰(PL)</option>
            </select>
        </div>
    </div>
    <div id="goods_attr-div" class="layui-form-item">
        <label for="goods_attr" class="layui-form-label">规格</label>
        <div class="layui-input-inline">
            <input type="text" id="goods_attr" class="layui-input" onkeypress="set_goods_blank()"
                   onchange="set_goods_blank()" list="goods_attr_list">
            <datalist id="goods_attr_list">
                {volist name="data.attr" id="value"}
                <option value="{$value.attr}">{$value.attr}</option>
                {/volist}
            </datalist>
        </div>
    </div>
    <div id="goods_pressure-div" class="layui-form-item">
        <label for="goods_pressure" class="layui-form-label">压力等级</label>
        <div class="layui-input-inline">
            <input type="text" id="goods_pressure" class="layui-input" onkeypress="set_goods_blank()"
                   onchange="set_goods_blank()" list="goods_pressure_list">
            <datalist id="goods_pressure_list">
                {volist name="data.pressure" id="value"}
                <option value="{$value.pressure}">{$value.pressure}</option>
                {/volist}
            </datalist>
        </div>
    </div>
    <div id="goods_piping-div" class="layui-form-item">
        <label for="goods_piping" class="layui-form-label">系列</label>
        <div class="layui-input-inline">
            <input type="text" id="goods_piping" class="layui-input" onkeypress="set_goods_blank()"
                   onchange="set_goods_blank()" list="goods_piping_list">
            <datalist id="goods_piping_list">
                {volist name="data.piping" id="value"}
                <option value="{$value.piping}">{$value.piping}</option>
                {/volist}
            </datalist>
        </div>
    </div>
    <div id="goods_ss-div" class="layui-form-item">
        <label for="goods_ss" class="layui-form-label">密封面</label>
        <div class="layui-input-inline">
            <input type="text" id="goods_ss" class="layui-input" onkeypress="set_goods_blank()"
                   onchange="set_goods_blank()" list="goods_ss_list">
            <datalist id="goods_ss_list">
                {volist name="data.ss" id="value"}
                <option value="{$value.ss}">{$value.ss}</option>
                {/volist}
            </datalist>
        </div>

    </div>
    <div class="layui-form-item">
        <label for="goods_material" class="layui-form-label">材质</label>
        <div class="layui-input-inline">
            <select name="goods_material" id="goods_material" class="layui-select"
                    onchange="set_material_data(this.value)">
                <option value="304">304</option>
                <option value="316L">316L</option>
                <option value="2205">2205</option>
                <option value="2507">2507</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label for="goods_md" class="layui-form-label">密度</label>
        <div class="layui-input-inline">
            <input id="goods_md" type="text" class="layui-input" disabled>
        </div>
    </div>
    <div id="strand_list" class="mukuai">
        <div class="layui-form-item">
            <label for="goods_pressing" class="layui-form-label">锻压毛重</label>
            <div class="layui-input-inline">
                <select name="goods_pressing" id="goods_pressing" class="layui-select"></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price" class="layui-form-label">毛胚不含税单价</label>
            <div class="layui-input-inline">
                <input type="text" id="goods_price" disabled class="layui-select">
            </div>
        </div>
    </div>
    <div id="strand_data" class="mukuai">
        <div class="hide layui-form-item" id="R1-div">
            <label class="layui-form-label" for="R1">外径</label>
            <div class="layui-input-inline"><input type="number" id="R1" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R2-div">
            <label class="layui-form-label" for="R2">内孔</label>
            <div class="layui-input-inline"><input type="number" id="R2" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="H1-div">
            <label class="layui-form-label" for="H1">片厚(不含台阶)</label>
            <div class="layui-input-inline"><input type="number" id="H1" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R3-div">
            <label class="layui-form-label" for="R3">台阶直径</label>
            <div class="layui-input-inline"><input type="number" id="R3" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="H2-div">
            <label class="layui-form-label" for="H2">台阶高度</label>
            <div class="layui-input-inline"><input type="number" id="H2" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="H3-div">
            <label class="layui-form-label" for="H3">总高</label>
            <div class="layui-input-inline"><input type="number" id="H3" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R4-div">
            <label class="layui-form-label" for="R4">根径</label>
            <div class="layui-input-inline"><input type="number" id="R4" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R5-div">
            <label class="layui-form-label" for="R5">对焊口直径</label>
            <div class="layui-input-inline"><input type="number" id="R5" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R6-div">
            <label class="layui-form-label" for="R6">壁厚</label>
            <div class="layui-input-inline"><input type="number" id="R6" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="N1-div">
            <label class="layui-form-label" for="N1">孔数</label>
            <div class="layui-input-inline"><input type="number" id="N1" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="R7-div">
            <label class="layui-form-label" for="R7">孔径</label>
            <div class="layui-input-inline"><input type="number" id="R7" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A1-div">
            <label class="layui-form-label" for="A1">外径余量</label>
            <div class="layui-input-inline"><input type="number" id="A1" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A2-div">
            <label class="layui-form-label" for="A2">内径余量</label>
            <div class="layui-input-inline"><input type="number" id="A2" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A3-div">
            <label class="layui-form-label" for="A3">片厚余量</label>
            <div class="layui-input-inline"><input type="number" id="A3" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A4-div">
            <label class="layui-form-label" for="A4">总高余量</label>
            <div class="layui-input-inline"><input type="number" id="A4" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A5-div">
            <label class="layui-form-label" for="A5">根径余量</label>
            <div class="layui-input-inline"><input type="number" id="A5" class="layui-input" onchange="set_weight()"
                                                   onkeypress="set_weight()" value=0></div>
        </div>
        <div class="hide layui-form-item" id="A6-div">
            <label class="layui-form-label" for="A6">对焊口直径余量</label>
            <div class="layui-input-inline">
                <input type="number" id="A6" class="layui-input" onchange="set_weight()" onkeypress="set_weight()"
                       value=0>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_forging_weight">锻打成品重量</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_net_worth_weight" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_forging_weight">锻打毛胚重量</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_forging_weight" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="cutting_materials_weight">下料</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="cutting_materials_weight" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_material_amount">圆钢材料单价</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_material_amount" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_material_amount2">圆钢材料单价(含税)</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_material_amount2" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_cutting_amount">圆钢切费</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_cutting_amount" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_forging_amount">锻打加工费</label>
            <div class="layui-input-inline">
                <select name="goods_forging_amount" id="goods_forging_amount">

                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_loss_weight">锻打损耗费用</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_loss_weight" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_forging_price">锻打毛坯单价</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" id="goods_forging_price" disabled>
            </div>
        </div>
    </div>
    <div class="mukuai">
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_weight1">单毛重</label>
            <div class="layui-input-inline">
                <input type="text" id="goods_weight1" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_weight2">单净重</label>
            <div class="layui-input-inline">
                <input type="text" id="goods_weight2" class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_weight3">废料重</label>
            <div class="layui-input-inline">
                <input type="text" id="goods_weight3" class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="mukuai">
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_number">数量</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_number" value="1" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="goods_unit">单位</label>
                <div class="layui-input-inline">
                    <input type="text" id="goods_unit" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price1">固溶单价</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price1" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price2">固溶费用</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price2" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price3">探伤费用</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price3" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price4">运费单价</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price4" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price5">运费</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price5" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" for="goods_price6">加工费</label>
            <div class="layui-input-inline">
                <input type="number" id="goods_price6" value="0" class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price7" class="layui-form-label" >车工费用</label>
            <div class="layui-input-inline">
                <input type="number" value="0" id="goods_price7"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">

            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price8" class="layui-form-label" >包装费用</label>
            <div class="layui-input-inline">
                <input type="number" value="0" id="goods_price8"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">

            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price9" class="layui-form-label">管理费用</label>
            <div class="layui-input-inline">
                <input type="number" value="0" id="goods_price9"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">

            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price10" class="layui-form-label">税款</label>
            <div class="layui-input-inline">
                <input type="number" value="0.87" id="goods_price10"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price11" class="layui-form-label">业务提成</label>
            <div class="layui-input-inline">
                <input type="number" value="0" id="goods_price11"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="goods_price12" class="layui-form-label">利润</label>
            <div class="layui-input-inline">
                <input type="number" value="0" id="goods_price12"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="info" class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" value="" id="info"  class="layui-input" onkeypress="get_total_price()"
                        onchange="get_total_price()">
            </div>
        </div>
    </div>
        <div class="layui-form-item" style="display: block;">
            <label class="layui-form-label">
            </label>
            <span class="total_amount">总费用:<b id="goods_total_price"></b></span>
            <button class="layui-btn" onclick="add_order()">添加</button>
            <button class="layui-btn" onclick="add_preview()">预览</button>
            <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
        </div>
        <!-- </form> -->
    </div>
    <style>
        .total_amount{
            display: inline-block;
            height: 38px;
            line-height: 38px;
            vertical-align: top;
            padding: 0 15px;
            /* background-color: #0dc316;
            color: #fff; */
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;
        }
        .total_amount b{
            font-size: 16px;

        }
    </style>
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;

            //自定义验证规则
            form.verify({
                name: function (value) {
                    if (value.length < 2) {
                        return '昵称至少得2个字符啊';
                    }
                }
            });

            //监听提交
            form.on('submit(add)', function (data) {
                let goods = {},
                    input_all = document.getElementsByTagName('input'),
                    select_all = document.getElementsByTagName('select');
                console.log(input_all.length, select_all.length);
                for (let i = 0; i < input_all.length; i++) {
                    goods[input_all[i].id] = input_all[i].value;
                }
                for (let i = 0; i < select_all.length; i++) {
                    goods[select_all[i].id] = select_all[i].value;
                }
                goods.amount = document.getElementById('amount').innerText;
                goods.uniqid = "{$data.order_no}";
                goods.day = "{$data.day}";
                goods.list = goods_message_list;
                //发异步，把数据提交给php
                $.ajax({
                    url: '/admin/order/save', // 你的 PHP 脚本的 URL
                    type: 'post', // 请求类型，可以是 'GET' 或 'POST'
                    dataType: 'json', // 预期服务器返回的数据类型
                    data: goods,
                    success: function (data) {
                        
                    }
                });
                return false;
            });
        });
    </script>
    <script>
        var weight = 0,
            goods_message_list = {},
            md = 0,
            goods_standard_name = '',
            gurongjiao = 0,
            goods_total_price = 0,
            goods_total_amount = 0,
            pale = 0,
            type_list = {
                'HG/T20592-2009': ['平焊法兰(PL)', '带颈平焊法兰(SO)', '对焊带颈法兰(WN)', '法兰盖(BL)', '承插焊法兰(SW)', '螺纹法兰(Th)', '对焊环松套法兰(PJ)'],
                'HG/T20615-2009': ['带颈平焊法兰(SO)', '对焊带颈法兰(WN)', '法兰盖(BL)', '承插焊法兰(SW)', '螺纹法兰(Th)', '对焊环松套法兰(PJ)'],
                '非标法兰': ['平焊法兰', '带颈平焊法兰', '对焊法兰', '法兰盖', '方法兰', '椭圆法兰', '平板法兰']
            },
            material = ['304', '316L', '2205', '2507'],
            jiagongfei = [
                {name:'260锤加工费',price:2.7},
                {name:'400气锤加工费',price:3.2},
                {name:'皮带锤加工费',price:3.5},
                {name:'碾环加工费',price:1.8}
            ],
            material_value = {
                '304': {
                    'md': 7.93,
                    'duanda_name': '260锤加工费',
                    'duanda_amount': 2.7,
                    'gurongjiao': 0.8,
                    'amount': 0.5,
                    'pale': 1.05,
                    'loss': 0.15,
                    'price': 12.06,
                    'price2':13.4,
                    'geban': 13.5,
                    'juanban': 14.2,
                    'feiliao': 9
                },
                '316L': {
                    'md': 7.93,
                    'duanda_name': '400气锤加工费',
                    'duanda_amount': 3.2,
                    'gurongjiao': 0.8,
                    'amount': 0.55,
                    'pale': 1.065,
                    'loss': 0.2,
                    'price': 21.51,
                    'price2':23.9,
                    'geban': 23.7,
                    'juanban': 24.4,
                    'feiliao': 16.5
                },
                '2205': {
                    'md': 7.93,
                    'duanda_name': '皮带锤加工费',
                    'duanda_amount': 3.5,
                    'gurongjiao': 1,
                    'amount': 0.9,
                    'pale': 1.07,
                    'loss': 0.23,
                    'price': 23.04,
                    'price2':25.6,
                    'geban': 26.5,
                    'juanban': 27,
                    'feiliao': 16.5
                },
                '2507': {
                    'md': 8.03,
                    'duanda_name': '碾环加工费',
                    'duanda_amount': 1.8,
                    'gurongjiao': 1.5,
                    'amount': 1.2,
                    'pale': 1.15,
                    'loss': 0.3,
                    'price': 29.7,
                    'price2':33.0,
                    'geban': 34,
                    'juanban': 35,
                    'feiliao': 17.5
                }
            };
        starnd_list = {
            all:['R1', 'R2', 'H1', 'R3', 'H2', 'H3', 'R4', 'R5', 'R6', 'N1', 'R7', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6'],
            //外径R1 内孔 R2 片厚 H1 台阶直径 R3 台阶高度 H2 总高 H3 根径 R4 对焊口直径 R5 壁厚 R6 孔数 N1 孔径 R7 外径余量 A1 内径余量 A2 片厚余量 A3 总高余量 A4 根径余量 A5 对焊口直径余量 A6
            '平焊法兰': ['R1', 'R2', 'H1', 'R3', 'N1', 'R7', 'A1', 'A2', 'A3'],
            '带颈平焊法兰': ['R1', 'R2', 'H1', 'R3', 'H2', 'H3', 'R4', 'R5', 'R6', 'N1', 'R7', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6'],
            '对焊法兰': ['R1', 'R2', 'H1', 'R3', 'H2', 'H3', 'R4', 'R5', 'N1', 'R7', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6'],
            '法兰盖': ['R1', 'N1', 'R7', 'A1', 'A3'],
            '方法兰': ['R1', 'R2', 'H1', 'R3', 'N1', 'R7', 'A1', 'A2', 'A3'],
            '椭圆法兰': ['R1', 'R2', 'H1', 'R3', 'N1', 'R7', 'A1', 'A2', 'A3'],
            '平板法兰': ['R1', 'R2', 'H1', 'R3', 'N1', 'R7', 'A1', 'A2', 'A3']
        }
        goods_name = document.getElementById('goods_name');
        set_goods_name('HG/T20592-2009');
        set_material_data('304');
        function set_goods_name(value) {
            let list = type_list[value], string = '';
            console.log(list);
            list.forEach(item => {
                string += '<option value="' + item + '">' + item + '</option>'
            });
            goods_name.innerHTML = string;
            if (value == '非标法兰') {
                // strand_data
                document.getElementById('goods_attr-div').style = 'display:none';
                document.getElementById('goods_pressure-div').style = 'display:none';
                document.getElementById('goods_piping-div').style = 'display:none';
                document.getElementById('goods_ss-div').style = 'display:none';
                document.getElementById('strand_data').style = 'display:block';
                document.getElementById('strand_list').style = 'display:none';
            } else {
                document.getElementById('goods_attr-div').style = 'display:inline-block';
                document.getElementById('goods_pressure-div').style = 'display:binline-lock';
                document.getElementById('goods_piping-div').style = 'display:inline-block';
                document.getElementById('goods_ss-div').style = 'display:inline-block';
                document.getElementById('strand_list').style = 'display:block';
                document.getElementById('strand_data').style = 'display:none';
            }
            set_goods_strand(list[0]);
        }

        function set_material_data(value) {
            let data = material_value[value];
            md = document.getElementById('goods_md').value = data.md;
            pale = data.pale;
            gurongjiao = document.getElementById('goods_price1').value = data.gurongjiao;
            // goods_forging_weight
            document.getElementById('goods_material_amount').value = data.price;
            document.getElementById('goods_material_amount2').value = data.price2;
            document.getElementById('goods_cutting_amount').value = data.amount;
            document.getElementById('goods_forging_amount').innerHTML = '';
            jiagongfei.forEach(item=>{
                document.getElementById('goods_forging_amount').innerHTML += '<option value="' + item.price + '">' + item.name + '(' + item.price + ')</option>';
            });
            document.getElementById('goods_loss_weight').value = data.loss;
            document.getElementById('goods_forging_price').value = Math.round(data.duanda_amount + data.loss + data.price + data.amount, 2);
            get_total_price();
        }

        function set_goods_strand(value) {
            console.log(value);
            goods_standard_name = value;
            document.getElementById('goods_weight1').value = weight;
            document.getElementById('goods_price2').value = Math.round(weight * gurongjiao, 4);
            set_goods_blank();
            if (starnd_list[value]) {
                starnd_list.all.forEach(item => {
                    document.getElementById(item + '-div').style = 'display:none';
                });
                starnd_list[value].forEach(item => {
                    document.getElementById(item + '-div').style = 'display:inline-block';
                });
            }
            if (value == '带颈平焊法兰') {
                document.getElementById('R2').disabled = true;
            } else {
                document.getElementById('R2').disabled = false;
            }
            get_total_price();
        }

        function get_total_price() {
            let goods_price1 = parseFloat(document.getElementById('goods_price1').value),
                goods_price2 = parseFloat(document.getElementById('goods_price2').value),
                goods_price3 = parseFloat(document.getElementById('goods_price3').value),
                goods_price4 = parseFloat(document.getElementById('goods_price4').value),
                goods_price5 = parseFloat(document.getElementById('goods_price5').value),
                goods_price6 = parseFloat(document.getElementById('goods_price6').value);
                goods_price7 = parseFloat(document.getElementById('goods_price7').value),
                goods_price8 = parseFloat(document.getElementById('goods_price8').value),
                goods_price9 = parseFloat(document.getElementById('goods_price9').value),
                goods_price10 = parseFloat(document.getElementById('goods_price10').value),
                goods_price11 = parseFloat(document.getElementById('goods_price11').value),
                goods_price12 = parseFloat(document.getElementById('goods_price12').value),
                goods_price = parseFloat(document.getElementById('goods_price').value);
            goods_total_price = 
                    goods_price1 + goods_price2 + goods_price3 + goods_price4 + goods_price5 + goods_price6 + 
                    goods_price7 + goods_price8 + goods_price9 + goods_price11;
            document.getElementById('goods_price12').placeholder = (pale - 1) * goods_total_price;
            goods_total_price = (goods_price + goods_total_price) * weight + goods_price12;
            if(goods_total_price == NaN)goods_total_price = 0;
            document.getElementById('goods_total_price').innerText = Math.round(goods_total_price,2);
        }

        function set_goods_blank() {
            let goods_data = {
                    attr: document.getElementById('goods_attr').value,
                    pressure: document.getElementById('goods_pressure').value,
                    piping: document.getElementById('goods_piping').value,
                    ss: document.getElementById('goods_ss').value,
                    name:document.getElementById('goods_name').value,
                    material:document.getElementById('goods_material').value
                },
                string = '';
            $.ajax({
                url: '/fdata', // 你的 PHP 脚本的 URL
                type: 'post', // 请求类型，可以是 'GET' 或 'POST'
                dataType: 'json', // 预期服务器返回的数据类型
                data: goods_data,
                success: function (res) {
                    console.log(res);
                    if (res.code == 200) {
                        res.data.falan.forEach(item => {
                            string += '<option value="' + item.duanyazhongliang + '">' + item.changjia + '(' + item.duanyazhongliang + ')</option>';
                        });
                        weight = res.data['falan'][0].duanyazhongliang;
                        console.log(weight);
                        document.getElementById('goods_weight1').value = weight;
                    }
                    document.getElementById('goods_pressing').innerHTML = string;
                    if(res.data.price[0])
                        document.getElementById('goods_price').value = res.data.price[0].price;
                    else
                    document.getElementById('goods_price').value = 0;
                    document.getElementById('goods_price2').value = Math.round(weight * gurongjiao, 4);
                    get_total_price();
                }
            });
        }

        function add_order() {
            let goods = {},
                name = document.getElementById('goods_name').value,
                material = document.getElementById('goods_material').value,
                goods_attr = document.getElementById('goods_attr').value,
                goods_pressure = document.getElementById('goods_pressure').value,
                goods_piping = document.getElementById('goods_piping').value,
                goods_ss = document.getElementById('goods_ss').value,
                number = document.getElementById('goods_number').value,
                unit = document.getElementById('goods_unit').value,
                goods_weight1 = document.getElementById('goods_weight1').value;
                info = document.getElementById('info').value,
                uniqid = generateSimpleUID();
            let list = document.getElementById('list-message'),
                input_all = document.getElementsByTagName('input'),
                select_all = document.getElementsByTagName('select');
            console.log(input_all.length, select_all.length);
            for (let i = 0; i < input_all.length; i++) {
                goods[input_all[i].id] = input_all[i].value;
            }
            for (let i = 0; i < select_all.length; i++) {
                goods[select_all[i].id] = select_all[i].value;
            }
            goods.material = material;
            goods.number = number;
            goods.unit = unit;
            goods.goods_total_price = goods_total_price;
            goods.goods_total_weight = (goods_weight1 * number).toFixed(6);
            goods.goods_total_amount = (number * goods_total_price).toFixed(2);
            goods_message_list[uniqid] = goods;
            string = '<tr id="tr' + uniqid + '">';
            string += '<td>' + name + '</td>';
            string += '<td>' + goods_attr + '-' + goods_pressure + '-' + goods_piping + '-' + goods_ss + '</td>';
            string += '<td>' + material + '</td>';
            string += '<td>' + number + '</td>';
            string += '<td>' + unit + '</td>';
            string += '<td>' + goods_weight1 + '</td>';
            string += '<td>' + ((goods_weight1 * number).toFixed(6)) + '</td>';
            string += '<td>' + goods_total_price + '</td>';
            string += '<td>' + (number * goods_total_price).toFixed(2) + '</td>';
            string += '<td>' + info + '</td>';
            string += '<td><a href="javascript:del_tr(\'' + uniqid + '\');">删除</a></td>'
            string += '</tr>';
            list.innerHTML += string;
            showmsg();
        }

        function set_weight() {
            let R1 = parseFloat(document.getElementById('R1').value),
                R2 = parseFloat(document.getElementById('R2').value),
                H1 = parseFloat(document.getElementById('H1').value),
                R3 = parseFloat(document.getElementById('R3').value),
                H2 = parseFloat(document.getElementById('H2').value),
                H3 = parseFloat(document.getElementById('H3').value),
                R4 = parseFloat(document.getElementById('R4').value),
                R5 = parseFloat(document.getElementById('R5').value),
                R6 = parseFloat(document.getElementById('R6').value),
                N1 = parseFloat(document.getElementById('N1').value),
                R7 = parseFloat(document.getElementById('R7').value),
                A1 = parseFloat(document.getElementById('A1').value),
                A2 = parseFloat(document.getElementById('A2').value),
                A3 = parseFloat(document.getElementById('A3').value),
                A4 = parseFloat(document.getElementById('A4').value),
                A5 = parseFloat(document.getElementById('A5').value),
                A6 = parseFloat(document.getElementById('A6').value);
            console.log(goods_standard_name);
            if (goods_standard_name == '带颈平焊法兰') {
                R2 = (R5 - R6 * 2);
                document.getElementById('R2').value = R2;
            };
            console.log(R1, R2, H1, R3, H2, H3, R4, R5, R6, N1, R7, A1, A2, A3, A4, A5, A6);
            //外径R1 内孔 R2 片厚 H1 台阶直径 R3 台阶高度 H2 总高 H3 根径 R4 对焊口直径 R5 壁厚 R6 孔数 N1 孔径 R7 外径余量 A1 内径余量 A2 片厚余量 A3 总高余量 A4 根径余量 A5 对焊口直径余量 A6
            goods_weight1 = goods_net_worth_weight = (R1 * R1 / 4 * 3.1415926 * H1 + R3 * R3 / 4 * 3.1415926 * H2 + R4 * R4 / 4 + R4 * R5 / 4 + R5 * R5 / 4 * 3.1415926 * (H3 - H1 - H2)) * md / 1000000 - R2 * R2 / 4 * 3.1415926 * md * H3 / 1000000 - R7 * R7 / 4 * 3.1415926 * md * N1 * R7 / 1000000;
            goods_forging_weight = ((R1 + A1) * (R1 + A1) / 4 * 3.1415926 * (H1 + H2 + A3) + (H3 + A5) * (H3 + A5) / 4 + (H3 + A5) * (R5 + A6) / 4 + (R5 + A6) * (R5 + A6) / 4 * 3.1415926 * (H3 - H1 - H2)) * md / 1000 / 1000 - (R2 - A2) * (R2 - A2) / 4 * 3.1415926 * md * (H3 + A4) / 1000 / 1000;
            document.getElementById('goods_net_worth_weight').value = goods_net_worth_weight.toFixed(6);
            document.getElementById('goods_forging_weight').value = goods_forging_weight.toFixed(6);
            document.getElementById('cutting_materials_weight').value = (goods_forging_weight * 1.05).toFixed(6);
            document.getElementById('goods_weight1').value = goods_net_worth_weight.toFixed(6);
            document.getElementById('goods_weight2').value = goods_forging_weight.toFixed(6);
            weight = goods_net_worth_weight;
            get_total_price();
        }

        function del_tr(uniqid) {
            document.getElementById('tr' + uniqid).remove();
            goods_message_list[uniqid] = {};
        }

        function generateSimpleUID() {
            const timestamp = Date.now(); // 获取当前时间戳
            const randomNum = Math.random().toString(36).substring(7); // 生成一个随机的7位字符串
            return timestamp + randomNum;
        }
        var info_data = {php}echo json_encode($info['data']);{/php};
        {php}if(!empty($info['data'])){ {/php}
        showmsg();
        {php} } {/php}
    </script>
</body>
</html>